const http = require('http');
const server = http.createServer();
const Interface = require('./interface');

const interface = new Interface();

server.on("request", async (req, res) => {
  res.setHeader("Access-Control-Allow-Origin", "*");
  res.setHeader("Access-Control-Allow-Headers", "*");
  if (req.method === "OPTIONS") {
    res.status = 200;
    res.end();
    return ;
  }

  if (req.url === "/login") {
    await interface.login(req, res);
    return;
  }

  if (req.url === "/register") {
    await interface.register(req, res);
    return;
  }

  // if (req.url === "/) {
    
  // }
});

server.listen(8888, () => console.log("正在监听 8888端口");